import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
} from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/home',
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/Home.vue'),
  },
  {
    path: '/article/:id',
    name: 'detail',
    component: () => import('@/views/article/Detail.vue'),
  },
  {
    path: '/talks',
    component: () => import('@/views/Talks/Talks.vue'),
    redirect: '/talks/talks_main',
    children: [
      {
        path: 'talks_main',
        name: 'talks_list',
        component: () => import('@/views/Talks/childsComponents/TalksLeft.vue'),
      },
      {
        path: 'talks_main/:id',
        name: 'talks_detail',
        component: () => import('@/views/Talks/childsComponents/TalksInfo.vue'),
      },
    ],
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('@/views/about/About.vue'),
  },
  {
    path: '/pigeonhole',
    name: 'pigeonhole',
    component: () => import('@/views/pigeonhole/Pigeonhole.vue'),
  },
  {
    path: '/type',
    name: 'type_list',
    component: () => import('@/views/type/Type.vue'),
  },
  {
    path: '/type/:id',
    name: 'type_detail',
    component: () => import('@/views/type/childComponents/Item.vue'),
  },
  {
    path: '/word',
    name: 'word_list',
    component: () => import('@/views/word/Word.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  // history: createWebHistory(),
  routes,
})

router.afterEach((to, from, next) => {
  window.scrollTo(0, 0)
})
export default router
